package com.xiedafeng.www.view;

import com.xiedafeng.www.controller.EventController;
import com.xiedafeng.www.po.Event;
import com.xiedafeng.www.po.Notice;
import com.xiedafeng.www.po.User;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class CreateTipoffView {
    TextField content=new TextField();
    public void tipOff(User user, Event event){
        Text tip=new Text("请填写举报原因！");
        Button send=new Button("提交");
        send.setOnMouseClicked(mouseevent -> {
            try {
                send(user,event);
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
        GridPane gridPane=new GridPane();
        gridPane.add(tip,0,0);
        gridPane.add(content,0,1,1,2);
        gridPane.add(send,0,3);
        Scene scene=new Scene(gridPane);
        Stage stage=new Stage();
        stage.setScene(scene);
        stage.showAndWait();
    }
    private void send(User user,Event event) throws Exception {
        Notice notice=new Notice();
        notice.setNoticeContent(content.getText());
        EventController eventController=new EventController();
        eventController.tipOff(user,event,notice);
    }
}
